const app = getApp()
Component({
  data: {
    // selected: app.globalData.tabbarActive,
    selected: 0,
    color: "#7A7E83",
    selectedColor: "#3cc51f",
    list: [{
      pagePath: "/pages/home/home",
      iconPath: "../image/tabbar_icon_01.png",
      selectedIconPath: "../image/tabbar_icon_01_on.png",
      text: "当前报价",
      type: 'switchTab',
      loginType: false
    }, {
      pagePath: "/pages/order/list/list",
      iconPath: "../image/tabbar_icon_02.png",
      selectedIconPath: "../image/tabbar_icon_02_on.png",
      text: "我的账单",
      type: 'switchTab',
      loginType: true
    }, {
      pagePath: "/pages/user/user",
      iconPath: "../image/tabbar_icon_03.png",
      selectedIconPath: "../image/tabbar_icon_03_on.png",
      text: "个人中心",
      type: 'switchTab',
      loginType: false
    }]
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      const type = data.type
      const loginType = data.login
      if (loginType && !app.globalData.loginState) {
        wx.navigateTo({
          url: '/pages/login/empower/empower',
        })
        return
      }
      wx[data.type]({
        url
      })
    }
  }
})